Pascal’s “packed array of characters”—used to represent Macintosh resource types, for example—is not a string, but an integer. It can be represented by enclosing the data within single quotes, as in 'ICN#'. The format primitive can be used for proper display of such data.
_________________________________________________
 
"in" *330*
Input names: aString; SubString; [StartIndex]
Input types: string; string; [integer]
Defaults: StartIndex = 1
Output names: FoundIndex
Output types: integer
Description: If SubString occurs in aString at or after position StartIndex, FoundIndex is the index of the first character of this occurrence in aString. Otherwise, FoundIndex is 0. StartIndex must be positive.
Note: If SubString is an empty string, FoundIndex returns 1.
See also: "length", "join"
_________________________________________________
 
"join" *330*
Input names: String1; [String2; ...]
Input types: string; [string; ...]
Output names: Result
Output types: string
Description: Result is the concatenation of String1, ….
See also: "in", "length"
_________________________________________________
 
"length" *331*
Input types: string
Output types: integer
Description: Length is the number of characters in aString.
See also: "in", "join"
_________________________________________________
 
byte-length *331*
Input types: string
Output types: integer
Description: Returns the length of the specified string in bytes
_________________________________________________
 
format *331*
Input names: FormatString; [Data Item1; ...; Data ItemN]
Description: Creates a Formatted String from FormatString and the Data Items which are to be formatted. FormatString consists of arbitrary text interspersed with format items. Each Data Item is formatted according to the specification of its associated format item as described in the following Backus-Naur form.
(Note: curly brackets denote possible repetition of the enclosed symbols zero or more times. A hyphen denotes a range of characters, for example a-z means all characters from a to z.)
Each format item is:
o delimited by backslashes
o contains any number of alpha spaces or integer spaces, but not both
o contains at most one of < and >
o contains at most one of + and -
o contains at most one of . and #
o cannot contain alpha spaces if it contains . or #.
< means justify the item to the left. This is the default for text.
> means justify the item to the right. This is the default for numbers.
+ means always display the sign of a number.
- for an integer or based integer means format the Data Item as an unsigned integer.
For a real - means format the absolute value of the Data Item.
# means format the number as a based integer.
. means format the number as a floating point number.
If the Data Item is a string then the total number of alpha spaces in the format item determines the number of characters output to the Formatted String irrespective of the length of the Data Item string. When the format item does not define sufficient space for a textual data item, characters are truncated from the right.
If the Data Item is a number, the number of characters in the Formatted String equals the number of integer spaces plus any of the characters +, -, . or # that the format requires. When the format item does not define sufficient space for a numeric data item, asterisks are output to the Formatted String. If the format item specifies a floating point number then digits which follow the decimal point define the precision of the number.
If the Data Item is of any other type then it can only be formatted using an empty format item, that is, \\ . The Data Item will be unparsed into a string according to the standard rules of the Prograph parser.
An empty format item can also be used to format strings of arbitrary length or integers or reals into strings of variable length.
Examples:
Format Item Input Output (n = space)
test \\ of 23 "test 23 of"
\aaaaaa\ "waloon" "waloon"
\aaaaaa\ "loon" "loon n n"
\>aaaaaa\ "loon" "n n loon"
\aaaa\ 'STR#' "STR#"
\aa\ 'STR#' "R#"
\a\ 'STR#' "#"
\a\ 9 " " (a tab character)
\99\ 9 "n9"
\99\ -9 "-9"
\+99\ 9 "n+9"
\+99\ -9 "n-9"
\-99\ 9 "n9"
\-99\ -9 "**" (not enough space)
\-9999999999\ -9 "4294967287"
\99.99\ 1.236 "1.24"
\99.99\ 333.33 "*****" (not enough space)
\16#9999\ 19 "16#0013"
\16#9999\ -19 "-16#013"
\16#99\ 19 "16#13"
\16#9\ 19 "****" (not enough space)
See also: from-string, to-string
_________________________________________________
 
from-ascii *334*
Input types: list of integer
Output types: string
Description: aString is sequence of characters, the ASCII representations of which are the integers in aList.
See also: to-ascii, to-string, from-string, tokenize
_________________________________________________
 
from-string *334*
Input types: string
Output types: <not a class or Macintosh type> | Point | Rect
Description: Data is the value textually represented by aString.
See also: to-string, to-ascii, from-ascii, tokenize
_________________________________________________
 
integer-to-string *335*
Input type: integer
Output type: string
Description: String is the four character string representation of Integer.
Example: If Integer = 16#54455854 ( “TEXT” ), then String = “TEXT”.
See also: string-to-integer
_________________________________________________
 
middle *335*
Input types: string; integer; integer
Output types: string
Description: OutString is the N characters of InString beginning at Index.
See also: prefix, suffix, "in"
_________________________________________________
 
munge-string *335*
Input types: string; string [; string…]
Output types: string
Description: Search Main for ‘^#’ combinations, where # is from 0-9, and replace with the appropriate parameter text.
_________________________________________________
 
prefix *335*
Input types: string; integer
Output types: string; string
Description: Prefix is the leftmost N characters of InString. Suffix is the remaining characters.
Example: The following example extracts the first and last names; the space character separates the two names. The second root of the prefix primitive returns the last name, while suffix is used to strip the trailing blank from the first name.
 
See also: middle, suffix, "in"
_________________________________________________
 
string-length *336*
Input types: string
Output types: integer
Description: Returns the character length of the given string.
_________________________________________________
 
string-to-integer *336*
Input type: string
Output type: integer
Description: Integer is the integer represented by the four character string.
Example: If String = “TEXT”, then Integer = 16#54455854 ( ‘TEXT’ ).
See also: integer-to-string
_________________________________________________
 
suffix *337*
Input types: string; integer
Output types: string; string
Description: Suffix is the rightmost N characters of InString. Prefix is the remaining characters.
See also: middle, prefix, "in"
_________________________________________________
 
to-ascii *337*
Input types: string
Output types: list
Description: aList is the list of integers that are the ASCII representations of the characters of aString.
See also: from-ascii, from-string, tokenize
_________________________________________________
 
to-string *337*
Input types: <not a class or Macintosh type> | Point | Rect
Output types: string
Description: aString is the textual representation of Data.
See also: from-string, to-ascii, from-ascii, tokenize
_________________________________________________
 
tokenize *338*
Input types: string
Output types: list
Description: aString is divided into tokens according to the following grammar, in such a way that the leftmost tokens are as long as possible. The list Tokens consists of pairs of the form (Type Token), where Token is one of the tokens found and Type is an integer from 1 to 5 representing token types <reserved>, <string>, <atom>, <integer>, and <real> respectively. If a substring is encountered that cannot be parsed into any of these token types, Tokens is terminated with the pair (0 NULL).